# 如今抢红包越来越盛行，下面就模拟一个红包分配程序，先输入
# 一个红包金额，然后输入红包的数量。结果显示哪些人抢到了多少金金额的红包。具体如下：
# 【1】金额按照输入的红包数量随机分配
# 【2】姓名自行准备，可以通过一组姓和一组名自由组合。
# #准备姓、名信息，后期根据姓+名组合成姓名
# xin=（‘张’，‘王’，‘李’，‘赵‘，‘陈’，‘钱’，‘，‘周’，‘吴’，‘郑，‘冯，‘蒋’，‘沈’，‘韩’，’杨）
# ming=（进，‘刚，‘鹏，’兰，‘爱国，‘建华，‘庆余，‘榕，‘花，‘华，‘洁”，‘霞，‘强，‘丽丽，‘辰）

import random


class Red_envelope:
    def __init__(self):
        self.amount = 0
        self.person_number = 0
        self.last_name = ("张", "王", "李", "赵", "陈", "钱", "周", "吴", "郑", "冯",
                          "蒋", "沈", "韩", "杨")
        self.first_name = ("进", "刚", "鹏", "兰", "爱国", "建华", "庆余", "榕", "花", "华",
                           "洁", "霞", "强", "丽丽", "辰")
        self.person_name = []
        self.distribute_amount = []

    def generate_name(self):
        try:
            temp_person_number = self.person_number
            while temp_person_number > 0:
                temp_name = random.choice(self.last_name) + random.choice(
                    self.first_name)
                if temp_name not in self.person_name:
                    self.person_name.append(temp_name)
                    temp_person_number -= 1
        except:
            pass

    def distribute_money(self):
        for i in range(self.person_number - 1):
            temp_money = eval("%.2f" % (random.uniform(0, self.amount)))
            self.distribute_amount.append(temp_money)
            self.amount -= temp_money
        self.distribute_amount.append(eval("%.2f" % self.amount))

    def playing(self):
        self.amount = eval(input("输入红包金额："))
        self.person_number = int(input("输入人数："))
        self.generate_name()
        self.distribute_money()
        for i in range(self.person_number):
            print("{} 抢到红包 {}元".format(self.person_name[i],
                                       self.distribute_amount[i]))


if __name__ == "__main__":
    this_project = Red_envelope()
    this_project.playing()